package com.freecloud.javabasics.design.proxy.mybatis.supper;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 反射方法封装，可直接调用proceed方法简化调用
 * @Author: maomao
 * @Date: 2021-04-11 18:10
 */
public class FreeInvocation {

    private final Object target;
    private final Method method;
    private final Object[] args;

    public FreeInvocation(Object target, Method method, Object[] args) {
        this.target = target;
        this.method = method;
        this.args = args;
    }

    public Object getTarget() {
        return target;
    }

    public Method getMethod() {
        return method;
    }

    public Object[] getArgs() {
        return args;
    }

    public Object proceed() throws InvocationTargetException, IllegalAccessException {
        return method.invoke(target, args);
    }
}
